Skip to content

Variable assignment from pipes and redirections#105

Open
Krush206 wants to merge 5 commits intotcsh-org:masterfrom
Krush206:readfile
Open

Variable assignment from pipes and redirections#105
Krush206 wants to merge 5 commits intotcsh-org:masterfrom
Krush206:readfile

Conversation

@Krush206
Copy link

In recognition of Bourne-compatible Shells and Mashey Shell, I came up with an implementation for assigning variables from pipes and redirections. Normal assignment reads until EOF or a newline is found. Indexed assignment reads until EOF. This is implemented for environment variable assignment as well. In order to avoid confusion with manual assignment, assignment from pipes and redirections is only possible if the variable name doesn't precede the assignment operator [equal sign]. This means subsequent names in a single command (e.g: set a b c) will be assigned from a pipe or redirection. If the name precedes the assignment operator, subsequent names, even if preceded or not by the assignment operator, won't read from a pipe or redirection.

This work also provides a fix for pipes and piped built-ins, at the cost of having piped built-ins forked. I don't think this cost should be taken badly, since most (if not all) Bourne-compatible Shells fork piped built-ins. The fix remedies the issue regarded here, on blank output from pipes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant